1. Field of the Invention
The present invention relates generally to an improved data processing system and in particular to a method and apparatus for optimizing performance in a data processing system. Still more particularly, the present invention provides a computer implemented method, apparatus, and computer usable program code for identifying and adjusting for overhead caused by instrumentation code.
2. Description of the Related Art
In analyzing and enhancing performance of a data processing system and the applications executing within the data processing system, it is helpful to know which software modules, routines, and/or methods executing on a data processing system are using system resources. Effective management and enhancement of data processing systems requires knowing how and when various system resources are being used. Performance tools are used to monitor and examine a data processing system to determine resource consumption as various software applications are executing within the data processing system. For example, a performance tool may identify the most frequently executed modules and instructions in a data processing system, or may identify those modules which allocate the largest amount of memory or perform the most input/output requests. Hardware performance tools may be built into the system or added at a later point in time. Software performance tools also are useful in data processing systems, such as personal computer systems, which typically do not contain many, if any, built-in hardware performance tools.
One known software performance tool is a profiler. A profiler is a program that monitors the execution of an application or program using one or more metrics. These metrics may take various forms. For example, the metrics tracked by a profiler may include, for example, without limitation, the cycles and number of instructions executed. With instructions, the number of instructions executed while a routine is active also may be tracked. These and other metrics are examples of information that may be collected by a profiler for analysis and for use to improve performance of an application.
One example of a profiler is a trace tool, which may use more than one technique to provide trace data that indicates execution flows for an executing program. One technique keeps track of particular sequences of instructions by logging certain events as they occur. This technique is referred to as an event-based profiling technique. For example, a trace tool may log every entry into and every exit from a module, subroutine, method, function, or system component. Alternately, a trace tool may log the requester and the amounts of memory allocated for each memory allocation request. Corresponding pairs of records similar to entry-exit records also are used to trace the execution of arbitrary code segments, starting and completing input/output or data transmission, and for many other events of interest.
Measuring execution of code in a data processing system perturbs the data processing system. In other words, monitoring the execution causes changes in the execution that would not be present if the monitoring did not occur. This effect is well understood in the study of elementary particle physics and is known as the Heisenberg uncertainty principle. With software profiling, the cost associated with the tracing can severely affect the system being profiled. The effect may include disruption of the cache or the instruction pipeline or simply the overhead associated with the tracing.
One effect that may be measured is the overhead associated with the execution of instrumentation code within the execution flows of the application program. As the application program executes, the instrumentation may incur significant overhead in the form of calls to obtain system information, such as a call to obtain a current timestamp for a trace record. This cost also is referred to as instrumentation overhead.
Therefore, it would be advantageous to provide a method and system to compensate for the disruptions described above during the profiling of code.